using System;
using System.Collections.Generic;
using System.Text;
using DDW.Collections;

namespace DDW
{
	public class BaseAccessExpression : PrimaryExpression
	{
		public BaseAccessExpression()
		{
		}
		public BaseAccessExpression(IdentifierExpression identifier)
		{
			this.identifier = identifier;
		}
		public BaseAccessExpression(ExpressionList expressions)
		{
			this.expressions = expressions;
		}


		private IdentifierExpression identifier;
		public IdentifierExpression Identifier
		{
			get { return identifier; }
			set { identifier = value; expressions = null; }
		}

		private ExpressionList expressions;
		public ExpressionList Expressions
		{
			get { return expressions; }
			set { expressions = value; identifier = null; }
		}

		public override void ToSource(StringBuilder sb)
		{
			sb.Append("base");
			if (identifier != null)
			{
				sb.Append(".");
				identifier.ToSource(sb);
			}
			else if (expressions != null)
			{
				sb.Append("[");
				expressions.ToSource(sb);
				sb.Append("]");
			}
		}
	}
}
